package arithmetic;

/**
 * 数组的 复制、反转、查找（线性查找、二分法查找）
 * 
 * @author: yyfei
 * @email: yyfei123@qq.com
 */
public class ArrayCopy {
	public static void main(String[] args) {
		String[] arr = new String[] { "AA", "BB", "CC", "DD" };
		for (int i = 0; i < arr.length; i++) {
			System.out.print(arr[i] + ",");
		}
		/**
		 * 数组的复制
		 * 
		 */
		// 新的数值
		String[] arrCy = new String[arr.length];
		for (int i = 0; i < arr.length; i++) {
			arrCy[i] = arr[i];
		}
		System.out.println("\n");
		// 打印数组
		for (int i = 0; i < arrCy.length; i++) {
			System.out.print(arrCy[i] + ",");
		}

		/**
		 * 数组的反转
		 */
		// 方法一：
		for (int i = 0; i < arr.length/2; i++) {
			String temp=arr[i];
			arr[i]=arr[arr.length-1-i];
			arr[arr.length-1-i]=temp;
		}

		System.out.println("\n");
		for (int i = 0; i < arr.length; i++) {
			System.out.print(arr[i] + ",");
		}

	}
}
